<?php
session_start();
include 'import_pcview.php';
$response_array = array();

// check contrller
if (! isset( $_REQUEST[PARAM_CONTROLLER]) || empty( $_REQUEST[PARAM_CONTROLLER])) {
	
	$response_array[STATUS] = STATUS_ERROR;
	$response_array[MESSAGE] = MESSAGE_NOT_DEFINE_CONTROLLER;
	echo json_encode( $response_array);

} else if (! isset( $_REQUEST[PARAM_ACTION]) || empty( $_REQUEST[PARAM_ACTION])) { // check action
	
	$response_array[STATUS] = STATUS_ERROR;
	$response_array[MESSAGE] = MESSAGE_NOT_DEFINE_ACTION;
	echo json_encode( $response_array);

} else {
	
	// get controller and action
	$controller = $_REQUEST[PARAM_CONTROLLER];
	$action = $_REQUEST[PARAM_ACTION];
	
	switch ($controller) {
		case PVALUE_CONTROLLER_PAGE_USERS :
			$ctrl = new UserController();
			
			switch ($action) {
				case PVALUE_ACTION_SUBMIT_CHECK_LOGTIN :
					$response_array = $ctrl->checkLogin();
					echo json_encode( $response_array);
					break;
				
				case PVALUE_ACTION_SUBMIT_LOGOUT :
					$response_array = $ctrl->userLogout();
					echo json_encode( $response_array);
					break;
				
				case PVALUE_ACTION_SUBMIT_USER_LOGTIN :
					$response_array = $ctrl->userLogin();
					echo json_encode( $response_array);
					break;
				
				case PVALUE_ACTION_SUBMIT_USER_REGISTOR :
					$response_array = $ctrl->userRegist();
					echo json_encode( $response_array);
					break;
				
				case PVALUE_ACTION_SUBMIT_NEWS_REGISTOR :
					$response_array = $ctrl->newRegist();
					echo json_encode( $response_array);
					break;
				
				default :
					$response_array[STATUS] = STATUS_ERROR;
					$response_array[MESSAGE] = MESSAGE_NOT_DEFINE_ACTION;
					echo json_encode( $response_array);
					break;
			}
			break;
		
		default :
			$response_array[STATUS] = STATUS_ERROR;
			$response_array[MESSAGE] = MESSAGE_NOT_DEFINE_CONTROLLER;
			echo json_encode( $response_array);
			break;
	}
}
?>